import { Module, Global } from '@nestjs/common';
import { DbService } from './db.service';
import { TypegooseModule } from 'nestjs-typegoose';
import { User } from './model/user.model';

const model=TypegooseModule.forFeature([User])
@Global()
@Module({
  imports:[
    TypegooseModule.forRootAsync({
      useFactory(){
        return {
           uri:process.env.DB_URL,
           useNewUrlParser:true
        }
      }
    }),
    model
  ],
  providers: [
    DbService],
  exports: [DbService,model],
})
export class DbModule {}
